package celiasoft.itasalib.query.resultparser;

import java.util.List;

import org.htmlcleaner.TagNode;
import org.w3c.dom.Document;

import celiasoft.itasalib.query.ResultsMetaInfo;
import celiasoft.itasalib.structures.DataElement;

public abstract class IQueryResultParser {

	public abstract List<DataElement> parse(Document doc, ResultsMetaInfo meta);
	
	public List<DataElement> parse(TagNode root, ResultsMetaInfo meta){
		return null;
	}

	
	protected void setMetaData(Document doc, ResultsMetaInfo meta) {

		if(doc == null){
			meta.thereIsMoreData(false);
			return;
		}
		
		int page = W3CParsingHandler.parseIntValue(doc, "page");
		int pages = W3CParsingHandler.parseIntValue(doc, "pages");
		
		meta.thereIsMoreData(!(page == -1 || pages == -1 || page >= pages));
	}
	
}
